from fastapi import APIRouter
from APP.app.docugen.services.ai_ppt_service import AiPPTService
from APP.config.log_conf import log
from APP.common.respones.response_schema import response_base

aippt_router = APIRouter() 

@aippt_router.get("/aippt",
                  summary='AI生成ppt'
                  )
async def ppt(topic: str,pages: int):
    
    # 调用llm生成PPT内容
    ppt_content = await AiPPTService.generate_ppt_content(topic, pages)
    log.info(f'生成PPT内容: {ppt_content}')
    #生成ppt文件
    try:
        p = await AiPPTService.generate_ppt_file(topic,ppt_content)
        log.info('PPT文件生成成功')
    except Exception as e:
        log.error(f'PPT文件生成失败: {e}')
        return response_base.fail(data=f'PPT文件生成失败: {e}')
    return response_base.fast_success(data='PPT文件生成成功')
